var log = require('./logs').logs;
function routerplay(ccd, pathname, request, response,query) { 
log.info(request.method + '请求');
if (request.method === 'OPTIONS') {
    response.writeHead(200, {
                "Content-Type": "text/html",
                "Access-Control-Allow-Origin": "*",
                "Access-Control-Allow-Methods": "GET",
                "Access-Control-Allow-Headers": "x-requested-with,content-type,token,deviceid,apptype,devicetype,appversion"
              });
    response.write(JSON.stringify({code:0, msg: 'ok'}));
    response.end();
    log.info('OPTIONS 请求响应成功');
    return
} 
  if(typeof ccd[pathname] === 'function'){
    return ccd[pathname](request, response,query);
  }else{
    log.info("没有找到网页 => " + pathname);
    response.writeHead(404, {"Content-Type": "text/plain"});
    response.write("404 Not found");
    response.end();
  }
}
exports.routerplay = routerplay;